import { Application } from 'egg';

export default (app: Application) => {
  const { controller, router } = app;

  // 基础路由
  router.get('/', controller.home.index);
  router.get('/health', controller.home.health);

  // 认证相关路由 (公开接口)
  router.post('/auth/register', controller.auth.register);
  router.post('/auth/login', controller.auth.login);

  // 用户
  router.post('/user/update-user-info', app.middleware.jwtAuth(), controller.user.updateProfile);
  
  // 公共接口
  router.post('/common/uplaod-img', app.middleware.jwtAuth(), controller.common.uploadImg);
  router.get('/common/get-region-list', app.middleware.jwtAuth(), controller.common.getRegionList);
  
  // 标签相关路由 (公开接口)
  router.get('/tags-list', controller.tag.getTagList);

  // 需要认证的路由
  router.get('/auth/user', app.middleware.jwtAuth(), controller.auth.getUserInfo);

  // 美食店相关路由 (需要认证)
  router.post('/add-restaurants', app.middleware.jwtAuth(), controller.restaurant.addRestaurant);
  router.post('/update-restaurants', app.middleware.jwtAuth(), controller.restaurant.updateRestaurant);
  router.post('/update-restaurants-base-info', app.middleware.jwtAuth(), controller.restaurant.updateRestaurantBaseInfo);
  router.get('/restaurants-list', app.middleware.jwtAuth(), controller.restaurant.getRestaurantList);
  router.get('/restaurants-detail', app.middleware.jwtAuth(), controller.restaurant.getRestaurantDetail);
  router.get('/restaurant/get-my-application', app.middleware.jwtAuth(), controller.restaurant.getMyApplicationList);
  router.post('/restaurants/:id/favorite', app.middleware.jwtAuth(), controller.restaurant.toggleFavorite);

  // 专属餐厅相关路由 (需要认证)
  router.post('/exclusive-restaurant/add-restaurants', app.middleware.jwtAuth(), controller.exclusiveRestaurant.addExclusiveRestaurant);
  router.post('/exclusive-restaurant/update-restaurants', app.middleware.jwtAuth(), controller.exclusiveRestaurant.updateExclusiveRestaurant);
  router.get('/exclusive-restaurant/get-info', app.middleware.jwtAuth(), controller.exclusiveRestaurant.getExclusiveRestaurantInfo);

  // 专属餐厅菜品分类与菜品 (需要认证)
  router.get('/exclusive-restaurant/categories-with-dishes', app.middleware.jwtAuth(), controller.exclusiveRestaurant.getCategoriesWithDishes);
  router.post('/exclusive-restaurant/add-categorie', app.middleware.jwtAuth(), controller.exclusiveRestaurant.addCategory);
  router.post('/exclusive-restaurant/update-categorie', app.middleware.jwtAuth(), controller.exclusiveRestaurant.updateCategory);
  router.post('/exclusive-restaurant/delete-categorie', app.middleware.jwtAuth(), controller.exclusiveRestaurant.deleteCategory);
  router.post('/exclusive-restaurant/add-dishe', app.middleware.jwtAuth(), controller.exclusiveRestaurant.addDish);
  router.post('/exclusive-restaurant/update-dishe', app.middleware.jwtAuth(), controller.exclusiveRestaurant.updateDish);
  router.post('/exclusive-restaurant/delete-dishe', app.middleware.jwtAuth(), controller.exclusiveRestaurant.deleteDish);

  // 专属餐厅点菜订单 (需要认证)
  router.post('/exclusive-restaurant/order/add', app.middleware.jwtAuth(), controller.exclusiveRestaurantOrder.addOrder);
  router.post('/exclusive-restaurant/order/cancel', app.middleware.jwtAuth(), controller.exclusiveRestaurantOrder.cancelOrder);
  router.get('/exclusive-restaurant/order/list', app.middleware.jwtAuth(), controller.exclusiveRestaurantOrder.listOrders);
  router.post('/exclusive-restaurant/order/update-status', app.middleware.adminAuth(), controller.exclusiveRestaurantOrder.updateOrderStatus);

  // 专属餐厅邀请 (需要认证)
  router.get('/exclusive-restaurant/invites', app.middleware.jwtAuth(), controller.exclusiveRestaurantInvite.listInvites);
  router.get('/exclusive-restaurant/accepted-restaurants', app.middleware.jwtAuth(), controller.exclusiveRestaurantInvite.listAcceptedRestaurants);
  router.post('/exclusive-restaurant/invite', app.middleware.jwtAuth(), controller.exclusiveRestaurantInvite.sendInvite);
  router.post('/exclusive-restaurant/invite/process', app.middleware.jwtAuth(), controller.exclusiveRestaurantInvite.processInvite);
  router.get('/exclusive-restaurant/invite/search', app.middleware.jwtAuth(), controller.exclusiveRestaurantInvite.searchUserByMobile);

  // 评论相关路由 (需要认证)
  router.post('/comment/create', app.middleware.jwtAuth(), controller.comment.addComment);
  router.get('/comment/get-comment-list', app.middleware.jwtAuth(), controller.comment.getCommentList);
  router.post('/comment/delete', app.middleware.jwtAuth(), controller.comment.deleteComment);

  // 管理员相关路由 (需要认证)
  router.get('/admin/restaurants-applications', app.middleware.adminAuth(), controller.restaurant.getApplicationList);
  router.post('/admin/restaurants-applications/audit', app.middleware.adminAuth(), controller.restaurant.auditRestaurant);
  router.get('/admin/exclusive-restaurant/get-application-list', app.middleware.adminAuth(), controller.exclusiveRestaurant.getExclusiveRestaurantApplyList);
  router.post('/admin/exclusive-restaurant/audit', app.middleware.adminAuth(), controller.exclusiveRestaurant.auditExclusiveRestaurant);

};